package com.jwdf.uda.http.action;

import android.content.Context;
import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.http.AHttpTaskService;
import com.jwdf.uda.http.ApiService;
import java.util.List;
import retrofit2.Call;

/**
 * Created by Administrator on 2016/9/7.
 */
public class QuestionEditAction extends AHttpTaskService<PbBean.PbResQuestionEditQuestion> {

    /**
     * 新增问题
     * @param context
     * @param title
     * @param categoryCode
     * @param descriptionList
     * @param voteOptionList
     * @return
     */
    public static QuestionEditAction newInstance(Context context, int questionid, String  title, int categoryCode, List<PbBean.PbBaseReqDescription> descriptionList, List<PbBean.PbBaseReqVoteOption>  voteOptionList, PbBean.PbSignBaseVoteLiveType type,int i){
        return new QuestionEditAction(context,questionid,title,categoryCode,descriptionList,voteOptionList,type,i);
    }

    private int mQuestionId;
    private String mTitle;
    private int mCategoryCode;
    private List<PbBean.PbBaseReqDescription> mDescriptionList;
    private List<PbBean.PbBaseReqVoteOption>  mVoteOptionList;
    private PbBean.PbSignBaseVoteLiveType type;
    private QuestionEditAction(Context context, int questionId , String  title, int categoryCode, List<PbBean.PbBaseReqDescription> descriptionList, List<PbBean.PbBaseReqVoteOption>  voteOptionList, PbBean.PbSignBaseVoteLiveType type,int i) {
        super(context,i);
        this.mQuestionId=questionId;
        this.mTitle=title;
        this.mCategoryCode=categoryCode;
        this.mDescriptionList=descriptionList;
        this.mVoteOptionList=voteOptionList;
        this.type=type;
    }
    @Override
    protected Call newRetrofitCall(ApiService apiService, PbBean.PbBaseClientInfo.Builder baseBuilder) {
        PbBean.PbReqQuestionEditQuestion.Builder builder = PbBean.PbReqQuestionEditQuestion.newBuilder();
        builder.setBaseClientInfo(baseBuilder);
        builder.setTitle(mTitle);
        builder.setCategoryCode(mCategoryCode);
        builder.setQuestionId(mQuestionId);
        builder.addAllDescription(mDescriptionList);
        builder.addAllVoteOption(mVoteOptionList);
        builder.setIsVote(type);
        return apiService.quizEdit(builder.build());
    }
}
